package com.imchen.cms.cmscore.service;

import com.imchen.cms.cmscore.dao.HtmlMapper;
import com.imchen.cms.cmscore.model.Html;
import com.imchen.cms.utils.ServiceUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;

/**
 * @author imchen
 * @create: 2019-02-12 14:45
 **/
@Service
public class HTMLService  implements BaseService<Html>{

    @Autowired
    private HtmlMapper mapper;

    @Override
    public HashMap<String, Integer> add(Html html) {
        int count = mapper.insertSelective(html);
        int id=html.getId();
        return ServiceUtil.toAddMap(count,id);
    }

    public int addOne(Html html){
        return mapper.insertSelective(html);
    }

    @Override
    public Html findById(int id) {
        return mapper.selectByPrimaryKey(id);
    }

    public Html findByArticleAndTemplateId(int articleId,int templateId){
        return mapper.selectByAidTid(articleId,templateId);
    }

    @Override
    public int removeById(int id) {
        return mapper.deleteByPrimaryKey(id);
    }

    @Override
    public int deleteById(int id) {
        return 0;
    }

    @Override
    public int update(Html html) {
        return mapper.updateByPrimaryKeySelective(html);
    }
}
